package com.ymttest.database.mapping.godmch;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Select;

import com.ymttest.database.model.Permissionitem;
import com.ymttest.database.model.agent_type;
import com.ymttest.database.model.country_info;
import com.ymttest.database.model.cs_info;
import com.ymttest.database.model.csrole;
import com.ymttest.database.model.invite_code;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.model.permission;

public interface permissionMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table permission
     *
     * @mbggenerated Mon Mar 18 10:16:10 CST 2019
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table permission
     *
     * @mbggenerated Mon Mar 18 10:16:10 CST 2019
     */
    int insert(permission record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table permission
     *
     * @mbggenerated Mon Mar 18 10:16:10 CST 2019
     */
    int insertSelective(permission record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table permission
     *
     * @mbggenerated Mon Mar 18 10:16:10 CST 2019
     */
    permission selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table permission
     *
     * @mbggenerated Mon Mar 18 10:16:10 CST 2019
     */
    int updateByPrimaryKeySelective(permission record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table permission
     *
     * @mbggenerated Mon Mar 18 10:16:10 CST 2019
     */
    int updateByPrimaryKey(permission record);
    
    @Select("select * from permission where roleid=#{roleid}")
    List<permission> selectPermission(Map m);
    @Select("select * from permission where roleid in (1,2,3,4)")
    List<permission> selectDefPermission(Map m);
    @Select("select * from csrole where MchId=#{MchId}")
    List<csrole> selectCsroleByMchId(Map m);
    @Select("select * from permissionitem where permissionitem.PermissionCode=#{PermissionCode}")
    List<Permissionitem> selectPermissionitemByPermissionCode(Map m);
    @Select("select * from permissionitem")
    List<Permissionitem> selectPermissionitem();
    @Select("select * from  permissioncategory where CategoryId=#{cid}")
    List<Map> selectPermissionCategory(Map m);
    
    @Select("select * from  cs_info where csid=#{csid} and mchid=#{mchid}")
    List<cs_info> selectCsInfo(Map m);
    @Select("select * from cs_info where csid = #{csid}")
    List<Map> selectCsInfoByCsId(Map m);
    
    @Select("select * from cs_info where mchid = #{mchid}")
    List<cs_info> selectCsInfoByMchId(Map m);
    
    @Select("<script>select  *   from agent_type "+
    "<where>"+
       "<if test='mchId != null' >"+
      "  and mchId = #{mchId,jdbcType=INTEGER}"+
     " </if>"+
     "<if test='agentType != null' >"+
     "   and agentType = #{agentType,jdbcType=INTEGER}"+
      "</if></where></script>")
    List<agent_type> selectAgentType(Map m);
    
    @Select("<script>select  *   from mch_relation "+
    	    "<where>"+
    	       "<if test='mchId != null' >"+
    	      "  and mchId = #{mchId,jdbcType=INTEGER}"+
    	     " </if>"+
    	     "<if test='parentMchId != null' >"+
   	      "  and parentMchId = #{parentMchId,jdbcType=INTEGER}"+
   	     " </if>"+
    	     "<if test='agentType != null' >"+
    	     "   and agentType = #{agentType,jdbcType=INTEGER}"+
    	      "</if></where></script>")
    List<mch_relation> selectMchRelation(Map m);
    
    @Select("select * from  mch_info where mchId=#{mchId}")
    List<mch_info> selectMchInfo(Map m);
    
    @Select("<script>select  *   from invite_code "+
    	    "<where>"+
    	       "<if test='mchId != null' >"+
    	      "  and mchId = #{mchId,jdbcType=INTEGER}"+
    	     " </if>"+
    	     "<if test='agentType != null' >"+
    	     "   and roleType = #{agentType,jdbcType=INTEGER}"+
    	      "</if></where></script>")
    List<invite_code> selectInviteCode(Map m);
    @Select("<script>select  *   from country_info "+
    	    "<where> state=0"+
    	       "<if test='country != null' >"+
    	      "  and country=#{country}"+
    	     " </if>"+
    	     "<if test='currency != null' >"+
    	     "   and currency = #{currency}"+
    	      "</if></where></script>")
//    @Select("select * from  country_info where country=#{country}")
    List<country_info> selectCountryInfo(Map m);
    
}